/*
 * @Author: long-xinyu2 2192763423@qq.com
 * @Date: 2025-04-01 10:09:57
 * @LastEditors: long-xinyu2 2192763423@qq.com
 * @LastEditTime: 2025-05-12 10:21:34
 * @FilePath: \algorithm\algorithm-training\lqb\acwing4_1.cpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#include<iostream>
#include<cstring>
#include<vector>
#include<map>
#include<cstdio>
#include<algorithm>
#include<string>
#include<string.h>
#include<queue>
#include<math.h>
#include<set>
#include<functional>
#include <bitset>
using namespace std;
using ull = unsigned long long;
using i128 = __int128_t;
//inline int inc(int x,int v,int mod){x+=v;return x>=mod?x-mod:x;}//代替取模+
#define endl '\n'
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
#define int long long

const int N = 1e5+10;
int n,m;

vector<char> ans;

int dx[] = {0,0,1};
int dy[] = {0,1,0};
char arr[1010][1010];

int flag = 0;

void dfs(int x,int y)
{
    if(x == n  && y == m)
    {
        flag = 1;
        for(int i = 0; i < ans.size(); i ++)
        {
            cout << ans[i];
        }
    }
    if(flag) return;
    for(int i = 1; i <= 2; i ++)
    {
        int newx = x + dx[i];
        int newy = y + dy[i];
        if(newx > n || newy > m) continue;
        if(arr[newx][newy] == '#') continue;

        if(i == 1)
        {
            ans.push_back('D');
            dfs(newx,newy);
            ans.pop_back();
            if(flag) return;
        }
        else 
        {
            ans.push_back('S');
            dfs(newx,newy);
            ans.pop_back();
            if(flag) return;
        }
    }
    if(flag) return;
}

void solve()
{  
    cin >> n >> m;

    for(int i = 1; i <= n; i ++)
    {
        for(int j = 1; j <= m; j ++)
        {
            cin >> arr[i][j];
        }
    }

    dfs(1,1);
}
signed main()
{
    int t = 1;
    //cin >> t;
    while(t --)
    {
        solve();
    }
}
